
<div class="tab-pane " id="grid_redrain">
    <!--	礼包奖品设置-->
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">红包雨抽奖规则</div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包雨时间</label>
                <div class="col-sm-8 col-xs-12">
                    {php $config['redrain_begintime']<$theme['begintime']?($config['redrain_begintime']=$theme['begintime']).($config['redrain_endtime']=$theme['endtime']):"";}
                    {php echo view_form_field_daterange('redrain_time', array('start'=>date('Y-m-d H:i:s',$config['redrain_begintime']),'end'=>date('Y-m-d H:i:s',$config['redrain_endtime'])), true);}
                    <span class="help-block">时间结束，将跳转至我的红包页</span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 control-label">展示时间</label>
                <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                    <table class='table' style="width: 500px">
                        <thead>
                        <tr>
                            <th>展示时间段</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="redrain_times">
                        {loop $config['redrain_times'] $key $w_rule}
                            <tr >
                                <td  class="col-sm-1 col-xs-12">
                                    <input id="add_time_picker{$key}" onclick="selectTime({$key})" class="time_picker form-control" name="redrain_times[]" type="text"  value="{$w_rule}"/>
                                </td>
                                <td  class="col-sm-1 col-xs-12"><a class='glyphicon glyphicon-remove' href='javascript:;' onclick='removeRedRainRule(this)'>删除</a></td>
                            </tr>
                        {/loop}
                        </tbody>
                    </table>
                    <a href="javascript:;" onclick="addRedrainTime();" style="background-color:#428bca;padding: 5px 10px; color: white;border-radius:5px;"><i class="glyphicon glyphicon-plus" ></i>添加时间段</a>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">允许员工参与抽奖</label>
                <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                    <label class="radio-inline">
                        <input name="redrain_has_worker" value="0" {if $config['redrain_has_worker']==0} checked="checked"{/if} type="radio">不允许
                    </label>
                    <label class="radio-inline">
                        <input name="redrain_has_worker" value="1" {if $config['redrain_has_worker']==1} checked="checked"{/if} type="radio"> 允许
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包雨地区限制</label>
                <div class="col-sm-8 col-xs-12">
                    <div class="input-group">
                        <span class="input-group-addon">城市：</span>
                        <input class="form-control span2" type="text" value="{$config['redrain_city']}"  name="redrain_city">
                        <span class="input-group-addon">定位方式：</span>
                        <div class="input-group-btn" style="width:130px">
                            <select class="form-control" name="redrain_locationtype">
                                <option value="0" {if $config['redrain_locationtype']==0}selected="selected"{/if}>IP地址</option>
                                <option value="1" {if $config['redrain_locationtype']==1}selected="selected"{/if}>微信GPS</option>
                            </select>
                        </div>
                    </div>
                    <span class="help-block" style="color: red;">请填写活动地区，例如：山东,青岛等。值为省,市,县,区则不限制地区。多个地区用英文“,”分割</span>
                    <span class="help-block" >IP地址：由于是移动联通电信等网络全省统一出口，尽量限制到省级</span>
                    <span class="help-block" >微信GPS：可定位到县，区，不过建议还是限制到市，且此功能会弹出客户授权定位</span>
                </div>
            </div>
            {if $config['redrain_get_type']==1 && $system['fenxiao04']==0  && $system['fenxiao07']==0 && $system['fenxiao071']==0}
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包发放时间</label>
                <div class="col-sm-6 col-xs-6">
                    <div class="input-group">
                        {php $comm4_time = [5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23];}
                        {php $config['comm4_time1'] = empty($config['comm4_time1'])?7:$config['comm4_time1'];}
                        {php $config['comm4_time2'] = empty($config['comm4_time2'])?23:$config['comm4_time2'];}
                        <select class="form-control" name="comm4_time1">
                            {loop $comm4_time $value}
                            <option value="{$value}" {if $config['comm4_time1'] == $value }selected="selected"{/if}>{$value}:00:00</option>
                            {/loop}
                        </select>
                        <span class="input-group-addon"> - </span>
                        <select class="form-control" name="comm4_time2">
                            {loop $comm4_time $value}
                            <option value="{$value}" {if $config['comm4_time2'] == $value }selected="selected"{/if}>{$value}:59:59</option>
                            {/loop}
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">是否开启大数据</label>
                <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                    <label class="radio-inline">
                        <input name="comm4dashuju" value="0" {if $config['comm4dashuju']==0} checked="checked"{/if} type="radio"> 开启【强烈推荐】
                    </label>
                    <label class="radio-inline">
                        <input name="comm4dashuju" value="1" {if $config['comm4dashuju']==1} checked="checked"{/if} type="radio"> 关闭
                    </label>
                    <span class="help-block" >防止盗刷红包非常有力的技术，强烈建议开启(前50名领取的不受此功能限制)</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包规则4</label>
                <div class="col-sm-8 col-xs-12">
                    <div class="input-group">
                        <span class="input-group-addon">同1网络</span>
                        <input class="form-control" placeholder="如:5" name="comm4ip" value="{if empty($config['comm4ip'])}5{else}{$config['comm4ip']}{/if}" type="text">
                    </div>
                    <span class="help-block" >同1个IP多少钱(单位:元)：同一个网络下的总红包钱数</span>
                </div>
            </div>
            {/if}
        </div>
    </div>
<!--    红包设置-->
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">红包设置 </div>
        <div class="panel-body">

            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">提现方式</label>
                <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                    <label class="radio-inline">
                        <input name="redrain_get_type" value="0" {if $config['redrain_get_type']==0} checked="checked"{/if} type="radio">员工审核帮提
                    </label>
                    <label class="radio-inline">
                        <input name="redrain_get_type" value="1" {if $config['redrain_get_type']==1} checked="checked"{/if} type="radio"> 用户自行提现
                    </label>
                </div>
            </div>

            <div class="form-group"  {if $system['redrain']!=2} style="display:none"{/if} >
                <label class="col-sm-2 col-xs-12 control-label">红包提现最低金额</label>
                <div class="col-sm-4 col-xs-12">
                    <input type="text" class="form-control"  placeholder="" name="redrain_min_amount"  value="{php echo empty($config['redrain_min_amount'])?0.3:$config['redrain_min_amount'];}">
                    <span class="help-block">提示：提现模式低于此金额，获得红包无法提现，默认最低提现金额0.3</span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">本次活动发放红包总金额</label>
                <div class="col-sm-4 col-xs-12">
                    <div class="input-group">
                        <input type="text" class="form-control"  placeholder="" name="redrain_total_amount"  value="{php echo empty($config['redrain_total_amount'])?0:$config['redrain_total_amount'];}">
                        <span class="input-group-addon">元</span>
                    </div>
                    <span class="help-block">提示：提现模式本次活动的发放红包总金额，发放完毕将不会发放,0代表不限制</span>
                </div>
            </div>

           <div class="form-group" >
                <label class="col-sm-2 col-xs-12 control-label">发放红包每日金额</label>
                <div class="col-sm-4 col-xs-12">
                    <div class="input-group">
                        <input type="text" class="form-control"  placeholder="" name="redrain_day_amount"  value="{php echo empty($config['redrain_day_amount'])?0:$config['redrain_day_amount'];}">
                        <span class="input-group-addon">元</span>
                    </div>
                    <span class="help-block">提示：提现模式本次活动的发放红包每日金额上限，发放完毕将不会发放,0代表不限制</span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">每人单次发放红包雨最大金额</label>
                <div class="col-sm-4 col-xs-12">
                    <div class="input-group">
                        <input type="text" class="form-control" style="min-width: 100px;" placeholder="" name="redrain_once_amount"  value="{php echo $config['redrain_once_amount'];}">
                        <span class="input-group-addon">元</span>
                    </div>
                    <span class="help-block">提示：每场红包雨下落红包的总额</span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包获得后的过期时间</label>
                <div class="col-sm-4 col-xs-12">
                    <div class="input-group">
                        <input type="text" class="form-control"  placeholder="" name="redrain_validity"  value="{php echo $config['redrain_validity'];}">
                        <span class="input-group-addon">小时</span>
                    </div>
                    <span class="help-block">提示：0小时为不过期</span>
                </div>
            </div>

        </div>
    </div>
    <!--  红包机会  -->
    <div class="panel panel-default" role="tabpanel" style="">
        <div class="panel-heading">红包雨抽奖机会</div>
        <div class="panel-body" style="">

            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包雨抽奖机会上限</label>
                <div class="col-sm-3 col-xs-12">
                    <div class="input-group">
                        <input type="number" class="form-control"  placeholder="" id="redrain_chance_limit" name="redrain_chance_limit"  value="{$config['redrain_chance_limit']}">
                        <span class="input-group-addon">次</span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">首次进入商家赠送红包雨抽奖机会</label>
                <div class="col-sm-3 col-xs-12">
                    <div class="input-group">
                        <input type="number" class="form-control"  placeholder="" id="redrain_shangjia_num" name="redrain_shangjia_num"  value="{$config['redrain_shangjia_num']}">
                        <span class="input-group-addon">次</span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">分享朋友圈加抽</label>
                <div class="col-sm-8 col-xs-12">
                    <div class="input-group">
                        <span class="input-group-addon">第1天</span>
                        <input type="number" class="form-control"  placeholder="" name="redrain_first_share_moment"  value="{$config['redrain_first_share_moment']}">
                        <span class="input-group-addon">第2天</span>
                        <input type="number" class="form-control"  placeholder="" name="redrain_second_share_moment"  value="{$config['redrain_second_share_moment']}">
                        <span class="input-group-addon">第3天</span>
                        <input type="number" class="form-control"  placeholder="" name="redrain_third_share_moment"  value="{$config['redrain_third_share_moment']}">
                    </div>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">好友下单加抽</label>
                <div class="col-sm-8 col-xs-12">
                    <div class="input-group">
                        <input type="number" class="form-control"  placeholder="" name="redrain_friend_order_num"  value="{$config['redrain_friend_order_num']}">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">转发好友\群加抽</label>
                <div class="col-sm-8 col-xs-12">
                    <div class="input-group">
                        <span class="input-group-addon">第1天</span>
                        <input type="number" class="form-control"  placeholder="" name="redrain_first_share_friend"  value="{$config['redrain_first_share_friend']}">
                        <span class="input-group-addon">第2天</span>
                        <input type="number" class="form-control"  placeholder="" name="redrain_second_share_friend"  value="{$config['redrain_second_share_friend']}">
                        <span class="input-group-addon">第3天</span>
                        <input type="number" class="form-control"  placeholder="" name="redrain_third_share_friend"  value="{$config['redrain_third_share_friend']}">
                    </div>
<!--                    <div class="input-group">-->
<!--                        <span class="input-group-addon">每天转发好友\群</span>-->
<!--                        <input type="number" class="form-control"  placeholder="" name="redrain_share_friend_num"  value="{$config['redrain_share_friend_num']}">-->
<!--                        <span class="input-group-addon">次；增加1次红包雨抽奖机会，最多转发好友\群</span>-->
<!--                        <input type="number" class="form-control"  placeholder="" name="redrain_share_friend_limit_day"  value="{$config['redrain_share_friend_limit_day']}">-->
<!--                        <span class="input-group-addon">天</span>-->
<!--                    </div>-->
                </div>
            </div>
            {if $system['daiyan']}
                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">好友到访</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <input type="number" class="form-control"  placeholder="" name="redrain_friend_view_num"  value="{$config['redrain_friend_view_num']}">
                            <span class="input-group-addon">个好友到访，增加1次红包雨抽奖机会;最多</span>
                            <input type="number" class="form-control" min=0 step=1  placeholder="" name="redrain_friend_view_limit"  value="{$config['redrain_friend_view_limit']}">
                            <span class="input-group-addon">次,有效期</span>
                            <input type="text" class="form-control"  placeholder="" name="redrain_help_validity"  value="{php echo $config['redrain_help_validity'];}">
                            <span class="input-group-addon">小时</span>
                        </div>
                    </div>
                    <span class="help-block">提示：最小值为1，有效期为第一位好友助力后开始计算</span>
                </div>
            {else}
                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">好友助力</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <input type="number" class="form-control"  placeholder="" name="redrain_friend_view_num"  value="{$config['redrain_friend_view_num']}">
                            <span class="input-group-addon">个好友助力，增加1次红包雨抽奖机会;最多</span>
                            <input type="number" class="form-control" min=0 step=1  placeholder="" name="redrain_friend_view_limit"  value="{$config['redrain_friend_view_limit']}">
                            <span class="input-group-addon">次,有效期</span>
                            <input type="text" class="form-control"  placeholder="" name="redrain_help_validity"  value="{php echo $config['redrain_help_validity'];}">
                            <span class="input-group-addon">小时</span>
                        </div>
                        <span class="help-block">提示：最小值为1，有效期为第一位好友助力后开始计算</span>
                    </div>
                </div>
            {/if}
        </div>
    </div>
    <!--    界面设置-->
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">界面设置 </div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包下落模式</label>
                <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                    <label class="radio-inline">
                        <input name="redrain_drop_mode" value="0" {if $config['redrain_drop_mode']==0} checked="checked"{/if} type="radio">密集
                    </label>
                    <label class="radio-inline">
                        <input name="redrain_drop_mode" value="1" {if $config['redrain_drop_mode']==1} checked="checked"{/if} type="radio"> 稀松
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">红包雨下落速度</label>
                <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                    <div class="input-group">
                        <input type="number" class="form-control" min="5" max="10"  name="redrain_speed"  value="{php echo $config['redrain_speed'];}">
                    </div>
                    <span class="help-block">提示：5-10区间数值</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">首页弹屏图标</label>
                <div class="col-sm-8 col-xs-12">
                    {php echo view_form_field_image('redrain_alert_icon',$config['redrain_alert_icon']);}
                    <span class="help-block">红包雨封面 <a style="color: #000000" href="https://css2020.yixuan.net/2020css/redrain/redmain_psd.zip" target="_blank">点击下载模版</a ></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 col-xs-12 control-label">首页右侧红包图标</label>
                <div class="col-sm-8 col-xs-12">
                    {php echo view_form_field_image('redrain_right_icon',$config['redrain_right_icon']);}
                    <span class="help-block">默认：https://css2020.yixuan.net//2020css/redrain/red_icon.png</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">活动规则：</label>
                <div class="col-sm-9 col-xs-12">
                    <table class='table'>
                        <thead>
                        <tr>
                            <th>规则序号</th>
                            <th>活动规则内容</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="redrain_rule_items">
                        {loop $config['redrain_rules'] $redrain_rule_item}
                        <tr >
                            <td class="col-sm-1 col-xs-12"><input name="redrain_rule_sort[]" type="text"
                                                                  class="form-control span3" value="{$redrain_rule_item['rule_sort']}"
                            /></td>

                            <td class="col-sm-10 col-xs-12"><input name="redrain_rule_content[]" type="text"
                                                                   class="form-control span3" value="{$redrain_rule_item['rule_content']}"
                            /></td>
                            <td>
                                <input  name="redrain_rule_id[]" type="hidden" value="{$redrain_rule_id['id']}" />
                                <a href='javascript:;' onclick='removeRedRainRule(this)'><i
                                        class='glyphicon glyphicon-remove'></i> 删除</a></td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                    <a href="javascript:;" onclick="addRedRainRule();"><i class="glyphicon glyphicon-plus" title="添加规则"></i>添加规则</a>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    var  minTime = '00:00:00';
    function addRedRainRule() {
        var html = "<tr>";
        html += '<td class="col-sm-1 col-xs-12"><input name="redrain_rule_sort[]" type="text" class="form-control span3" value="" /></td>';
        html += '<td class="col-sm-10 col-xs-12"><input name="redrain_rule_content[]" type="text" class="form-control span3" value="" /></td>';
        html += '<td><input  name="redrain_rule_id[]" type="hidden" value="" />&nbsp;<a href="javascript:;" onclick="removeRedRainRule(this)" ><i class="glyphicon glyphicon-remove"></i> 删除</a></td>';
        html += "</tr>";
        $("#redrain_rule_items").append(html);
    }
    function removeRedRainRule(obj) {
        $(obj).parent().parent().remove();
    }

    function addRedrainTime(){
        var k = $("#redrain_times").find('tr').size();
        var html = "<tr>";
        html += '<td><input id="add_time_picker'+k+'" onclick="selectTime('+k+')"  class="time_picker form-control" type="text" name="redrain_times[]" value=""/></td>';
        html += '<td><a href="javascript:;" onclick="removeRedRainRule(this)" ><i class="glyphicon glyphicon-remove"></i> 删除</a></td>';
        html += "</tr>";
        $("#redrain_times").append(html);
        $("#add_time_picker"+k).focus();
        selectTime(k);
    }

    function updateMinTime(k) {
        var TimesNum = $("input[name^='redrain_times']").length;
        if(TimesNum>1&&k>=1){
            var lastTime;
            $("input[name^='redrain_times']").each(function(i, el) {
                if(i==k-1){
                    lastTime =  $(this).val();
                }
            });
            minTime=lastTime.substr(8,5)+':00';
        }
    }

    function  selectTime(k){
        updateMinTime(k);
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            var $ = layui.jquery;
            laydate.render({
                elem: "#add_time_picker"+k
                ,type: 'time'
                ,format: 'HH:mm'
                ,trigger: 'click'
                ,range:true
                ,min:minTime
                ,done: function(value, date, endDate){
                    var arr = value.split('-');
                    var startTime =  arr[0];
                    var endTime = $.trim(arr[1]);
                    var startArr = startTime.split(':');
                    var endArr = endTime.split(':');
                    if(startArr[0]>endArr[0]){
                         layer.msg('结束时间不能大于开始时间');
                         return false;
                    }
                    if(startArr[0]===endArr[0]){
                        if(startArr[1]>=endArr[1]){
                            layer.msg('结束时间不能大于开始时间');
                            return false;
                        }
                    }
                }
            });
        });
    }

</script>

